
#include "main.h"

CONFIG_FILE ConfigFile;
 
unsigned char Config_Read( void )
{
	E2_LoadFrom((unsigned char*)&ConfigFile, E2_ADDR_CONFIG_FILE, sizeof(CONFIG_FILE) ); 
	if ( ConfigFile.UNUSABLE_2 == 0xFF )
		return 0xFF;
	
	return TRUE;
}	
 
void Config_Write( void )
{
	E2_SaveTo(E2_ADDR_CONFIG_FILE, (unsigned char*)&ConfigFile, sizeof(CONFIG_FILE) );
	Config_Read();
}
 
void Config_Init( void )
{
	if ( Config_Read() == 0xFF )
	{
		ConfigFile.CFG__APPARATUS_ENABLE = TRUE;
		ConfigFile.CFG__LOCATION_POLING_ENABLE = FALSE;
		ConfigFile.CFG__SEND_STATUS_IF_LOCATION_CHANGED = FALSE;
		ConfigFile.CFG__SEND_STATUS_IF_TURNS_ON_OFF = FALSE;
		ConfigFile.CFG__ALLOW_MANUAL_ENTER_MY_PHONE_NUMBER = TRUE;
		ConfigFile.CFG__SEND_CDRs_IF_TABLE_FULL = FALSE;
		ConfigFile.CFG__DISABLE_APPARATUS_IF_TABLE_FULL = FALSE;
		ConfigFile.CFG__SEND_STATUS_IF_COUNTER_LESS_THAN = FALSE;
		ConfigFile.CFG__SEND_STAUS_IF_SIM_CHANGED = FALSE;
		ConfigFile.CFG__DISABLE_APPARATUS_IF_SIM_CHANGED = TRUE;
		ConfigFile.CFG__SEND_STAUS_IF_TAMPER = FALSE;
		ConfigFile.CFG__DISABLE_APPARATUS_IF_TAMPER = FALSE;
		ConfigFile.CFG__INCLUDE_IN_CDR_TABLE_OFFICIAL_SMS = FALSE;
		ConfigFile.CFG__ALLOW_MANUAL_PREFIX_EDIT = FALSE;
		ConfigFile.CFG__UNUSABLE_BIT_15 = 0;

		ConfigFile.UNUSABLE_1 = 0;
		ConfigFile.UNUSABLE_2 = 0;
		
		Config_Write();
	}
} 


